﻿using System;

namespace Microsoft.Goldenlight.Framework
{
    /// <summary>
    /// 	Provides data for the PropertyChange event.
    /// </summary>
    /// <remarks>
    /// 	A PropertyChange event is raised when a property is being changed on a object. A PropertyChangeEventArgs object specifies the name and the value of the property that changing.
    /// </remarks>
    /// <typeparam name="T"> The type of the value in the EventArgs. </typeparam>
    public class PropertyChangeEventArgs<T> : EventArgs
    {
        #region Fields & Properties

        private readonly string _name;

        /// <summary>
        /// 	Gets the name of the property that changed.
        /// </summary>
        public string Name
        {
            get
            {
                return _name;
            }
        }

        private readonly T _oldValue;

        /// <summary>
        /// 	Gets the value of the property before the change.
        /// </summary>
        public T OldValue
        {
            get
            {
                return _oldValue;
            }
        }

        private readonly T _newValue;

        /// <summary>
        /// 	Gets the value of the property after the change.
        /// </summary>
        public T NewValue
        {
            get
            {
                return _newValue;
            }
        }

        #endregion

        #region Constructors

        /// <summary>
        /// 	Initializes a new instance of the PropertyChangeEventArgs class.
        /// </summary>
        /// <param name="name"> The name of the property that changed. </param>
        /// <param name="oldValue"> The value of the property before the change. </param>
        /// <param name="newValue"> The value of the property after the change. </param>
        public PropertyChangeEventArgs(string name, T oldValue, T newValue)
        {
            _name = name;
            _oldValue = oldValue;
            _newValue = newValue;
        }

        #endregion
    }
}